﻿#include "GamePause.h"
#include "GameSet.h"
gameState GamePause() {
	cleardevice();  // 清空屏幕
	// 加载游戏首页背景图片
	BeginBatchDraw();
	std::ifstream file_check("assets/picture/pause.png");
	if (file_check) {
		file_check.close(); // 关闭文件流后再加载图片
		loadimage(&bgimage, _T("assets/picture/pause.png"), windowWidth, windowHeight, true);
		putimage(0, 0, &bgimage);
	}
	EndBatchDraw();
	ExMessage msg = { 0 };
	while (true) {
		peekmessage(&msg, EX_KEY);
		if (msg.message == WM_KEYDOWN) {
			if (msg.vkcode == 'C') {  //按下 p 键返回游戏
				AutoSound();
				return GAME_PLAYING;
			}
			if (msg.vkcode == 'S') {  //按下 s 键进入设置
				AutoSound();
				GameSet();
				return GAME_PAUSE;
			}
			if (msg.vkcode == 'X') {  //按下 x 键返回主菜单
				AutoSound();
				Init();//重新初始化，我们不存储中途退出的游戏，如果还能继续，此处可以不初始化
				return HOME_PAGE;
			}
		}
	}
}